import { request } from '@/utils/request'
import type { CodeType, Patient, PatientList, User } from '@/types/user'
/**
 *
 * @param mobile 用密码登录
 * @param password
 */
export const loginBypassword = (mobile: string, password: string) => {
  return request<User>('/login/password', 'POST', { mobile, password })
}
/**
 *
 * @param mobile 获取手机验证码
 * @param type
 */
export const loginByCode = (mobile: string, type: CodeType) => {
  return request('/code', 'GET', { mobile, type })
}
/**
 *
 * @param mobile 手机验证码登录
 * @param code
 */
export const loginByMobile = (mobile: string, code: string) => {
  return request<User>('/login', 'POST', { mobile, code })
}
/**
 *
 * 获取用户信息
 *
 */
export const getUserInfo = () => {
  return request('/patient/myUser')
}
/**
 * 获取患者列表
 */
export const getPatientsList = () => {
  return request<PatientList>('/patient/mylist')
}
/**
 *
 * @param patient 添加患者列表
 */
export const addPatient = (patient: Patient) => {
  return request('/patient/add', 'POST', patient)
}
/**
 *
 * @param patient 编辑患者信息
 */
export const editPatient = (patient: Patient) => {
  return request('/patient/update', 'PUT', patient)
}
/**
 *
 * @param id 删除患者信息
 */
export const delPatient = (id: string) => {
  return request(`/patient/del/${id}`, 'DELETE')
}

/**
 * 查询患者详情
 * */
export const getPatientDetail = (id: string) =>
  request<Patient>(`/patient/info/${id}`)
